package br.com.klanpaia.Logon;


import org.andengine.engine.Engine;
import org.andengine.engine.handler.timer.ITimerCallback;
import org.andengine.engine.handler.timer.TimerHandler;
import org.andengine.util.debug.Debug;

import br.com.klanpaia.Game.MainActivity;

public class CenasManager {
	private MainActivity contexto;
	private Logon logon, logon2;
	public Engine enginer;
	int contagem=0;
	boolean ok = false;
	

	public CenasManager(MainActivity contexto) {
		super();
		this.contexto = contexto;
		enginer = contexto.getEngine();
	}

	public void carregarCenaPreloads(){
		logon =  new Logon(contexto, 100, 120, contexto.resource.logon1, false);
		logon2 =  new Logon(contexto, 100, 120, contexto.resource.logon2, true);
		//logon2 = new Logon1(contexto, 100, 120, contexto.resource.logon1, false);
	}
	
	public boolean IniciarLogons(){
		contexto.cena.attachChild(logon);
		
		enginer.registerUpdateHandler(new TimerHandler(0.01f * 800.0f, true, new ITimerCallback() {
			
			public void onTimePassed(TimerHandler pTimerHandler) {
				contagem++;
				switch (contagem) {
				case 1:
					contexto.cena.attachChild(logon2);
					break;
				default:
					ok = true;
					Debug.e("ok");
					break;
				}
				
				
            }
			
			
           
    })); 
	

		return ok;
	}


	
}
